/* eslint-disable semi */
/* eslint-disable semi */
/* eslint-disable quotes */
<template>
    <van-pull-refresh v-model="isLoading">
        <div class="all-body">
            <div class="TopList">
                <router-link to="/Address">
                    <van-icon class="Backlink"
                              name="arrow-left" />
                </router-link>

                <div class="TopList-span">
                    <span> 添加地址 </span>

                </div>

            </div>

            <div class="shadow"> </div>
            <div class="banner"
                 ref="scroll">
                <!-- 轮播图 -->
                <div id="topBanner"
                     class="hello-1">
                    <van-cell-group class="cell-Group">
                        <van-field v-model="compellation"
                                   class="cell-List"
                                   required
                                   label="真实姓名"
                                   placeholder="请输入您的真实姓名" />
                        <van-field v-model="phone"
                                   type="tel"
                                   class="cell-List"
                                   required
                                   label="联系电话"
                                   placeholder="请输入您的联系电话" />
                        <van-field v-model="postcode"
                                   type="number"
                                   class="cell-List"
                                   required
                                   label="邮政邮编"
                                   placeholder="请输入邮政编号" />
                        <van-field v-model="grtaddress"
                                   class="cell-List"
                                   required
                                   label="选择地区"
                                   placeholder="请选择所在地区" />
                        <van-field v-model="street"
                                   class="cell-List"
                                   required
                                   label="详细地址"
                                   placeholder="请输入详细地址" />

                    </van-cell-group>

                </div>

                <div class="lastadd"
                     @click="verification()">
                    <van-button class="add-button"
                                color="#41D08C"
                                round
                                type="info">立即验证</van-button>
                </div>

                <div class="adddiv"> </div>

            </div>
        </div>
    </van-pull-refresh>
</template>

<script>
import TabBar from "./TabBar.vue";


//引入其他子组件
export default {
    components: {
        TabBar
    },
    // eslint-disable-next-line space-before-function-paren
    data() {
        return {
            count: 0,
            isLoading: false,
            index: 0,
            message: "",
            compellation: "",
            phone: "",
            postcode: "",
            grtaddress: "",
            street: "",
            compellationarr: ["王纪林"],
            phonearr: ["18515069755"],
            postcodearr: ["650051"],
            grtaddressarr: ["云南省-昆明市-盘龙区"],
            streetarr: ["拓东街道建工大厦二十一楼"],
            bannerimages: [
                { id: 0, imgSrc: require("../assets/images/a16.jpg") }
                // { id: 1, imgSrc: require("../assets/images/a18.jpg") }
            ],
            middleimages: [{ id: 0, imgSrc: require("../assets/images/none.png") }]
        };
    },

    mounted() {
        // 上拉加载
    },
    // eslint-disable-next-line space-before-function-paren
    // created:vue生命周期中的钩子函数，在这个时间点，data中的数据已经注入到响应式系统中
    created() { },

    methods: {
        afterRead(file) {
            // 此时可以自行将文件上传至服务器
            console.log(file);
        },
        //弹出提示
        showNumber() {
            this.$toast({
                message: "字数不能超过200个"
            });
        },

        verification() {
            let compellation = this.compellation;
            let phone = this.phone;
            let postcode = this.postcode;
            let grtaddress = this.grtaddress;
            let street = this.street;
            //姓名验证
            if (!compellation) {
                this.$toast({
                    message: "请输入真实姓名！"
                });
            } else if (!phone) {
                this.$toast({
                    message: "请输入手机号码！"
                });
            } else if (!postcode) {
                this.$toast({
                    message: "请输入邮政编号！"
                });
            } else if (!grtaddress) {
                this.$toast({
                    message: "请输入所在地区！"
                });
            } else if (!street) {
                this.$toast({
                    message: "请输入详细地址！"
                });
            } else if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(compellation)) {
                this.$toast({
                    message: "请输入正确真实姓名！"
                });
            } else if (!/^[1][3-9][0-9]{9}$/.test(phone)) {
                this.$toast({
                    message: "请输入正确手机号！"
                });
            } else if (!/[1-9][0-9]{5}/.test(postcode)) {
                this.$toast({
                    message: "请输入正确邮政编码！"
                });
            } else if (
                !/^([\u4e00-\u9fa5]+(省|自治区)-)?[\u4e00-\u9fa5]+市-[\u4e00-\u9fa5]+(区|县)$/.test(
                    grtaddress
                )
            ) {
                this.$toast({
                    message: "请输入正确所在地址！"
                });
            } else if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(street)) {
                this.$toast({
                    message: "请输入详细住址！"
                });
            } else {
                for (var i = 0; i < this.compellationarr.length; i++) {
                    if (
                        compellation == this.compellationarr[i] &&
                        phone == this.phonearr[i] &&
                        postcode == this.postcodearr[i] &&
                        grtaddress == this.grtaddressarr[i] &&
                        street == this.streetarr[i]
                    ) {
                        this.$toast({
                            message: "输入成功！"
                        });
                    }
                }
            }
        }
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* //自定义.css的样式路径 */
/* @import "../css/HomePage.css"; */

* {
    padding: 0;
    margin: 0;
}
body {
    background-color: #f6f6f6;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    margin: 0;
    display: block;
}
div {
    display: block;
    box-sizing: border-box;
}

.all-body {
    width: 100%;
    height: 100%;
    background-color: #f6f6f6;
}

.shadow {
    height: 1px;
    width: 100%;
    background: #f6f6f6;
}

.TopList {
    display: flex;
    width: 100%;
    height: 50px;
    font-size: 20px;
    text-align: left;
    background: #ffffff;
    line-height: 50px;
}
.Backlink {
    margin-top: 15px;
    margin-left: 15px;
    color: #888;
}
.TopList-span {
    display: flex;
    height: 20px;
    margin-top: 0px;
    margin-left: 110px;
    font-size: 15px;
    width: 60%;
}

.banner {
    width: 100%;
    height: 100%;
}
.hello-1 {
    width: 100%;
    height: auto;
    padding: 0 2.6%;
    background-color: #ffffff;
    text-align: left;
}

.hello-1 img {
    width: 99%;
    height: 150px;
    border-radius: 10px;
    pointer-events: none;
}

li {
    position: absolute;
}

.cell-Group {
    height: auto;
}
.van-cell--required::before {
    position: absolute;
    left: 0px;
    color: #ee0a24;
    font-size: 14px;
    content: '*';
}
.cell-List {
    display: flex;
    height: 40px;
    line-height: 40px;
    padding-left: 8px;
}
.cell-List-2 {
    display: flex;
    height: 130px;
    line-height: 48px;
    padding-left: 8px;
    color: #969799;
}
.updateImg {
    margin-top: 15px;
    margin-left: 95px;
}

.lastadd {
    background: #fff;
    width: 100%;
    padding: 30px 6% 0;
}

.lastadd {
    width: 100%;
    height: 100px;
    color: #fff;
    line-height: 50px;
    font-size: 18px;
}
.add-button {
    width: 100%;
    font-size: 18px;
    letter-spacing: 1px;
    height: 42px;
    line-height: 42px;
}

.adddiv {
    width: 100%;
    height: 315px;
    background: #f6f6f6;
}
</style>
